From: Andrew Cooper Date: Tue, 27 Jan 2015 20:38:11 +0000 (+0000) Subject: ocaml/xenctrl: Check return values from hypercalls X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~3829 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=3380f5b6270e6fa4b24313f8808e7625e4c5a6ba;p=xen.git ocaml/xenctrl: Check return values from hypercalls rather than blindly continuing and possibly using negative values. Signed-off-by: Andrew Cooper CC: Ian Campbell CC: Ian Jackson CC: Wei Liu CC: Dave Scott Acked-by: David Scott --- diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c b/tools/ocaml/libs/xc/xenctrl_stubs.c index f0810ebd6a..92d064f658 100644 --- a/tools/ocaml/libs/xc/xenctrl_stubs.c +++ b/tools/ocaml/libs/xc/xenctrl_stubs.c @@ -457,6 +457,9 @@ CAMLprim value stub_xc_vcpu_getaffinity(value xch, value domid, int i, len = xc_get_max_cpus(_H(xch)); int retval; + if (len < 1) + failwith_xc(_H(xch)); + c_cpumap = xc_cpumap_alloc(_H(xch)); if (c_cpumap == NULL) failwith_xc(_H(xch)); @@ -821,6 +824,12 @@ CAMLprim value stub_xc_version_version(value xch) caml_enter_blocking_section(); packed = xc_version(_H(xch), XENVER_version, NULL); + caml_leave_blocking_section(); + + if (packed < 0) + failwith_xc(_H(xch)); + + caml_enter_blocking_section(); retval = xc_version(_H(xch), XENVER_extraversion, &extra); caml_leave_blocking_section();